<template>
  <div class="app-container home">
    <div v-if="welCode" class="code_box">
      <p>邀请码链接：<span class="code_font">{{ welCode }}</span></p>
      <el-link :underline="false" icon="el-icon-document-copy" v-clipboard:copy="welCode" v-clipboard:success="clipboardSuccess" class="copy">复制</el-link>
    </div>
    <!-- <el-row>
      <el-col :span="8" v-for="(item,index) in tz" :key="index"> 
        <el-card class="box-card">
          {{item.name}}
          <el-divider></el-divider>
          <el-link type="primary" @click="toForm(item)">{{item.count}}</el-link>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8"> 
        <el-card class="box-card">
          {{fb.name}}
          <el-divider></el-divider>
          {{fb.count}}
        </el-card>
      </el-col>
      <el-col :span="8" v-for="(item,index) in ct" :key="index"> 
        <el-card class="box-card">
          {{item.name}}
          <el-divider></el-divider>
          {{item.amount}}
        </el-card>
      </el-col>
    </el-row> -->
    <p class="title textL">审核</p>
    <div class="flex_box">
      <div v-for="(item,index) in tz" :key="index" class="content_box">
        <p class="title paddt_20">{{item.name}}</p>
        <el-link type="primary" @click="toForm(item)" class="font_blue">{{item.count}}</el-link>
      </div>
    </div>
    <p class="title textL">资金</p>
    <div class="flex_box">
      <div v-for="item in ct.slice(0, 2)" :key="item.name" class="content_box2">
        <p class="title paddt_20">{{item.name}}</p>
        <p class="p1">{{item.amount}}</p>
      </div>
    </div>
    <div class="flex_box">
      <div v-for="item in ct.slice(2, 5)" :key="item.name" class="content_box">
        <p class="title paddt_20">{{item.name}}</p>
        <p class="p1">{{item.amount}}</p>
      </div>
    </div>
  </div>
</template>

<script>
import { getInfo } from '@/api/login'
import { getCtData,getFbData,getTzData} from "@/api/census";
export default {
  name: "Index",
  data() {
    return {
      // 版本号
      version: "3.8.3",
      ct:[],
      fb:[],
      tz:[],
      welCode: '',
    };
  },
  mounted(){
    this.getCtList();
    this.getFbList();
    this.getTzList();
    this.getUser();
  },
  methods: {
    getUser() {
      getInfo().then(res => {
        res.user.roles.forEach(item => {
          if (item.roleName === '代理角色') {
              this.welCode = 'https://carbonrh.com/register?code=' + res.user.welCode;
            }
          })
        }).catch(error => {
          reject(error)
        })
    },
    /** 复制代码成功 */
    clipboardSuccess() {
      this.$modal.msgSuccess("复制成功");
    },
    getCtList(){
      getCtData().then(res=>{
        this.ct = res.data;
      })
    },
    getFbList(){
      getFbData().then(res=>{
        this.fb = res.data;
      })
    },
    getTzList(){
      getTzData().then(res=>{
        this.tz = res.data;
      })
    },
    toForm(e){
      this.$router.push({ path: e.path });
    }
  },
};
</script>

<style scoped lang="scss">
.home {
  height: calc(100vh - 84px);
  background-color: #f3f3f3;
  .title {
    font-size: 16px;
    color: #1a1a1a;
    margin: 10px 0 10px 0;
  }
  .textL {
    text-align: left;
  }
  .flex_box {
    display: flex;
    .content_box {
      width: calc((100% - 50px)/ 3);
      border-radius: 10px;
      margin-right: 25px;
      margin-bottom: 25px;
      text-align: center;
      background-color: #ffffff;
      padding-bottom: 30px;
    }
    .content_box:last-child {
      margin-right: 0;
    }
    .content_box2 {
      width: calc((100% - 25px)/ 2);
      border-radius: 10px;
      margin-right: 25px;
      margin-bottom: 25px;
      text-align: center;
      background-color: #ffffff;
      padding-bottom: 30px;
    }
    .content_box2:last-child {
      margin-right: 0;
    }
    .font_blue {
      color: #409efe;
      font-size: 18px;
      font-weight: 600;
      padding-top: 20px;
    }
    .p1 {
      color: #000000;
      font-size: 18px;
      font-weight: 600;
      margin: 0;
      padding-top: 20px;
    }
  }
  .paddt_20 {
    padding-top: 20px;
  }
  .code_box {
    display: flex;
    align-items: center;
    width: 100%;
    border-radius: 10px;
    margin-right: 25px;
    margin-bottom: 25px;
    text-align: center;
    background-color: #ffffff;
    padding: 5px 20px;
  }
  .code_font {
    margin-right: 20px;
    color: #409efe;
  }
}
.el-col{
  color: rgb(134, 128, 128);
  font-weight: bold;
  margin: 10px 0 0 0;
}
.link{
  height: 20px;
}
</style>

